import 'package:chathouse/constant/my_color.dart';
import 'package:chathouse/pages/guide/about_page.dart';
import 'package:chathouse/util/font_utils.dart';
import 'package:chathouse/util/image_utils.dart';
import 'package:chathouse/widgets/form_widgets/form_widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../constant/app_constant.dart';
import '../../constant/res.dart';
import 'package:chathouse/util/base_utils.dart';
import 'package:get/get.dart';

import '../../public/Styles.dart';
import '../../public/event_bus.dart';
import '../expert/expert_root_page.dart';

//註冊成功頁
class RegisterSuccessPage extends StatelessWidget {
  const RegisterSuccessPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: 1.sw,
        color: Colors.white,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            ImageUtils.image(Res.login_logo, width: 145.w, height: 160.w)
                .setContainer(margin: EdgeInsets.only(top: 100.w)),
            Text(
              "Chat House",
              style: getTextStyle(34.sp,
                  fontType: FontType.MID, color: MyColors.green_5714540),
            ).setContainer(margin: EdgeInsets.only(top: 3.w)),
            Text(
              "屋測測",
              style: getTextStyle(42.sp,
                  fontType: FontType.MID, color: MyColors.green_5714540),
            ).setContainer(margin: EdgeInsets.only(top: 3.w)),
            Text(
              AppConstant.userRole == UserRole.c ? "註冊成功" : "服務專家註冊成功",
              style: getTextStyle(32.sp,
                  fontType: FontType.DEFAULT, color: Colors.black),
            ).setContainer(margin: EdgeInsets.only(top: 80.w)),
            const Spacer(),
            AppConstant.userRole == UserRole.c
                ? FormWidgets.getTextButton("屋測測簡介及教學", MyColors.red_2166474)
                    .setContainer(
                        margin: EdgeInsets.only(
                            left: 78.w, right: 78.w, bottom: 104.w))
                    .setOnClickListener(() {
                    Get.to(const AboutPage());
                  })
                : getToBWidget(),
          ],
        ),
      ),
    );
  }

  Widget getToBWidget() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Text(
          "請填上詳細資料\n以獲得生意機會",
          style:
              getTextStyle(25.sp, fontType: FontType.MID, color: Colors.black),
        ).setContainer(margin: EdgeInsets.only(bottom: 25.w)),
        FormWidgets.getTextButton("立即編輯詳細資料", MyColors.green_69157154)
            .setContainer(
                margin: EdgeInsets.only(left: 78.w, right: 78.w, bottom: 104.w))
            .setOnClickListener(() {
          Get.offAll(const ExpertRootPage());
          Future.delayed(const Duration(milliseconds: 50)).then((value) {
            eventBus.fire(UpdateRootIndexEvent(2));
            Future.delayed(const Duration(milliseconds: 100)).then((value) {
              eventBus.fire(ToEditAccountEvent());
            });
          });
        })
      ],
    );
  }
}
